<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con">
            <span>新建投标总结</span><div class="move_title"></div><?php include "../public/sub.php";?></div>
    </div>
    <div class="main-container">
        <div class="block-generic">


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="bidid" class="layui-input bidid" onclick="openPage('../public/choose_bid.php?dom=bidid&page=bid_sum&zhongluo=1','80%','80%')">
                            <div class="choose_div" id="bidid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_bid.php?dom=bidid&page=bid_sum&zhongluo=1','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目状态</label>
                        <div class="layui-input-block">
                            <input type="text" id="state_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="number" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <input type="text" id="bidtype_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目所在地</label>
                        <div class="layui-input-block">
                            <input type="text" id="areas" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方</label>
                        <div class="layui-input-block">
                            <input type="text" id="zhaoname" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <input type="text" id="zhaotype_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标负责人</label>
                        <div class="layui-input-block">
                            <input type="text" id="touer_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标日期</label>
                        <div class="layui-input-block">
                            <input type="text" id="kaidt" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标方式</label>
                        <div class="layui-input-block">
                            <input type="text" id="tou_kaitype" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <input type="text" id="chanid_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目属性</label>
                        <div class="layui-input-block">
                            <input type="text" id="business_name" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标报价(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="tou_fee" placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">综合排名</label>
                        <div class="layui-input-block">
                            <input type="text" name="rank" id="rank" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">商务标排名</label>
                        <div class="layui-input-block">
                            <input type="text" name="rank_business" id="rank_business" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">技术标排名</label>
                        <div class="layui-input-block">
                            <input type="text" name="rank_technology" id="rank_technology" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">中标/未中标说明</label>
                        <div class="layui-input-block">
                            <textarea id="reason" name="reason" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>


            <?php include '../public/upinfo.php'?>
        </div>



        <div class="block-generic">
            <div class="layui-form-item height_auto">
                <div class="short_table_list" key="1">
                    <div class="opt-btn-group">
                        <div><span>明细</span></div>
                        <div>
                            <button type="button" onclick="ctrlv_data_open()" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn">粘贴新增</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_add_row">插入行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_row">删除行</button>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary mingxibtn short_table_del_all">删除全部</button>
                        </div>
                    </div>
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th style="width: 45px">序号</th>
                            <th>投标单位</th>
                            <th>投标报价(元)</th>
                            <th>下浮率(%)</th>
                            <th>特殊条款</th>
                            <th>综合排名</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody class="short_table_tbody">
                        <tr>
                            <td style="width: 45px">1</td>
                            <td><input type="text" class="layui-input unit"></td>
                            <td><input type="number" class="layui-input money"></td>
                            <td><input type="number" class="layui-input rate"></td>
                            <td><input type="text" class="layui-input clause"></td>
                            <td><input type="text" class="layui-input sort"></td>
                            <td><input type="text" class="layui-input explain"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>
</form>
<script>

    var str = '';
    str += '<tr>';
    str += '<td style="width: 45px">1</td>';
    str += '<td><input type="text" class="layui-input unit"></td>';
    str += '<td><input type="number" class="layui-input money"></td>';
    str += '<td><input type="number" class="layui-input rate"></td>';
    str += '<td><input type="text" class="layui-input clause"></td>';
    str += '<td><input type="text" class="layui-input sort"></td>';
    str += '<td><input type="text" class="layui-input explain"></td>';
    str += '</tr>';
    short_table_opt_func(str,1);

    layui.use(['laytp', 'form'], function() {
        var form = layui.form;
        render_input_attr();

        public_upload_file_load('upload_files');


        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();
            data.field.bidid = get_choose_val('bidid');

            formValid('bidid');
            if(data.field.bidid == undefined || !data.field.bidid){
                validRes = false;
            }
            if(!validRes){return false;}


            var list = ['']; var message = '';
            $('.short_table_tbody tr').each(function (i) {
                var unit = $('.unit').eq(i).val();
                var money = $('.money').eq(i).val();
                var rate = $('.rate').eq(i).val();
                var clause = $('.clause').eq(i).val();
                var sort = $('.sort').eq(i).val();
                var explain = $('.explain').eq(i).val();
                var arr = {
                    unit:unit,
                    money:money,
                    rate:rate,
                    clause:clause,
                    sort:sort,
                    explain:explain
                };
                list.push(arr);
            });
            if(message !== ''){
                facade.error(message);return false;
            }
            if(list.length === 1){
                facade.error('请填写投标情况记录');return false;
            }
            data.field.list = list;

            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_bid_sum_add, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });





    var ctrlv_field_name = [
        {field: 'unit', name:'投标单位'},
        {field: 'money', name:'投标报价(元)',type:'number'},
        {field: 'rate', name:'下浮率(%)',type:'number'},
        {field: 'clause', name:'特殊条款'},
        {field: 'sort', name:'综合排名'},
        {field: 'explain', name:'备注'},
    ];
    function ctrlv_data_show(list) {
        if(list.length > 0){
            var nums = $(".short_table_tbody tr").length;
            for (var key in list){
                var str = '';
                nums++;
                str += '<tr>';
                str += '<td style="width: 45px">'+nums+'</td>';
                str += '<td><input type="text" class="layui-input unit" value="'+list[key].unit+'"></td>';
                str += '<td><input type="number" class="layui-input money" value="'+list[key].money+'"></td>';
                str += '<td><input type="number" class="layui-input rate" value="'+list[key].rate+'"></td>';
                str += '<td><input type="text" class="layui-input clause" value="'+list[key].clause+'"></td>';
                str += '<td><input type="text" class="layui-input sort" value="'+list[key].sort+'"></td>';
                str += '<td><input type="text" class="layui-input explain" value="'+list[key].explain+'"></td>';
                str += '</tr>';
                $('.short_table_tbody').append(str);
            }
        }
        render_date();
        render_from();
    }
</script>
</body>
</html>
